#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <string.h>

#define MEM_COPY_NO_DMA 0
#define MEM_COPY_DMA    1

/* ./dma_test <dma|nodma> */

void print_usage(char *name)
{
	printf("Usage:\n");
	printf("%s <dma | nodma>", name);
}

int main(int argc, char **argv)
{
	int fd;

	if(argc != 2)
	{
		print_usage(argv[0]);
		return -1;
	}
	
	fd = open("/dev/s3c_dma", O_RDWR);
	if(fd < 0)
	{
		printf("can't open dma\n");
		return -1;
	}
	if(strcmp(argv[1], "dma") == 0)
	{
		while(1)
		{
			ioctl(fd, MEM_COPY_DMA);
		}
	}
	else if(strcmp(argv[1], "nodma") == 0)
	{
		while(1)
		{
			ioctl(fd, MEM_COPY_NO_DMA);
		}
	}
	else
	{
		print_usage(argv[0]);
	}

	return 0;
}



